package yunquan.wang.jbpm5.web;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.drools.SystemEventListenerFactory;

public class TaskServiceTools {
private static org.jbpm.task.service.TaskService taskServiceInDb;
	
	public  static 	org.jbpm.task.service.TaskService getTaskStore()
	{
		if(taskServiceInDb==null)
		{
			taskServiceInDb=new TaskServiceTools().createServerTaskService();
		}
		return taskServiceInDb;
	}
	
	private org.jbpm.task.service.TaskService createServerTaskService() {
		//JPA属性设置
		   Map<String, String> map = new HashMap<String, String>();
		  map.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
		  EntityManagerFactory emf =Persistence.createEntityManagerFactory("org.jbpm.task",map);
		  org.jbpm.task.service.TaskService taskService = new org.jbpm.task.service.TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
		return taskService;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
